package util;

import byggeTegner.ByggeTegner;
import context.*;


import javax.swing.JSpinner;
import javax.swing.SpinnerNumberModel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

// ********************************************************************
// *** CLASS: ValueSpinner
// ********************************************************************
public abstract class ValueSpinner extends JSpinner implements Context.Constants
{ //private static final boolean DEBUG=true; // Overriding Context.Constants.DEBUG
  static final String TAG="util.ValueSpinner";
  static final long serialVersionUID=0; // AD'HOC
  
  abstract public void update(double value);
  
  public ValueSpinner(double value,double MINIMUM,double MAXIMUM,double stepSize)
  { super(new SpinnerNumberModel(value,MINIMUM,MAXIMUM,stepSize));
    addChangeListener(new ChangeListener()
    { public void stateChanged(ChangeEvent e)
      { Double value=(Double)getValue();
   	    update(value.doubleValue()); ByggeTegner.repaint();
      }	
    });	
  }
}
